package com.huilian.cloud.module.system.dal.mysql.dept;

import com.huilian.cloud.framework.mybatis.core.mapper.BaseMapperX;
import com.huilian.cloud.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.huilian.cloud.module.system.controller.admin.dept.vo.dept.DeptListReqVO;
import com.huilian.cloud.module.system.dal.dataobject.dept.OrgDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.Collection;
import java.util.List;

@Mapper
public interface DeptMapper extends BaseMapperX<OrgDO> {

    default List<OrgDO> selectList(DeptListReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<OrgDO>()
                .likeIfPresent(OrgDO::getGroupName, reqVO.getName())
                );
    }

    default OrgDO selectByParentIdAndName(Integer parentId, String name) {
        return selectOne(OrgDO::getParentId, parentId, OrgDO::getGroupName, name);
    }

    default Long selectCountByParentId(Integer parentId) {
        return selectCount(OrgDO::getParentId, parentId);
    }

    default List<OrgDO> selectListByParentId(Collection<Integer> parentIds) {
        return selectList(OrgDO::getParentId, parentIds);
    }



}
